home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Other Langs
/
Tickle-4.0 (tcl)
/
src
/
XTCL_setfile.c
< prev
next >
Wrap
Text File
|
1993-11-18
|
5KB
|
170 lines
/*
** This source code was written by Tim Endres
** Email: time@ice.com.
** USMail: 8840 Main Street, Whitmore Lake, MI 48189
**
** Some portions of this application utilize sources
** that are copyrighted by ICE Engineering, Inc., and
** ICE Engineering retains all rights to those sources.
**
** Neither ICE Engineering, Inc., nor Tim Endres,
** warrants this source code for any reason, and neither
** party assumes any responsbility for the use of these
** sources, libraries, or applications. The user of these
** sources and binaries assumes all responsbilities for
** any resulting consequences.
*/
#include <Types.h>
#include <Resources.h>
#include <QuickDraw.h>
#include <Windows.h>
#include <Memory.h>
#include <Files.h>
#include "tcl.h"
#include "xtcl.h"
#define sprintf sprintf_drvr
#define FALSE (Boolean)0
void
XTCLEntry(argc, argv, xpb)
int argc;
char **argv;
XTCLParmBlk *xpb;
{
char *ptr;
int i, j;
Handle resultH;
char buffer[256];
char pascal_name[256];
ParamBlockRec pb;
resultH = xpb->resultH;
strcpy(pascal_name, argv[1]);
c2pstr(pascal_name);
pb.fileParam.ioCompletion = 0;
pb.fileParam.ioVRefNum = 0;
pb.fileParam.ioNamePtr = pascal_name;
pb.fileParam.ioFDirIndex = 0;
pb.fileParam.ioFVersNum = 0;
PBGetFInfo(&pb, FALSE);
if (pb.fileParam.ioResult != noErr) {
sprintf(buffer, "error #%d retrieving info for '%.32s'.",
pb.fileParam.ioResult, argv[1]);
SetHandleSize(resultH, strlen(buffer) + 1);
if (MemError() == noErr)
strcpy(*resultH, buffer);
xpb->result = TCL_ERROR;
}
else {
xpb->result = TCL_OK;
for (i = 2 ; i < argc ; i+=2) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'a': /* attributes (lowercase = 0, uppercase = 1) [*] */
ptr = argv[i+1];
for (ptr = argv[i+1] ; *ptr ; ptr++) {
switch (*ptr) {
case 'L': case 'l': /* Locked / Not */
if (*ptr == 'L')
pb.fileParam.ioFlFndrInfo.fdFlags |= 0x8000;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~0x8000;
break;
case 'V': case 'v': /* Invisible / Visible */
if (*ptr == 'V')
pb.fileParam.ioFlFndrInfo.fdFlags |= fInvisible;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~fInvisible;
break;
case 'B': case 'b': /* Bundled / Not */
if (*ptr == 'B')
pb.fileParam.ioFlFndrInfo.fdFlags |= fHasBundle;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~fHasBundle;
break;
case 'S': case 's': /* System / Not */
if (*ptr == 'S')
pb.fileParam.ioFlFndrInfo.fdFlags |= 0x1000;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~0x1000;
break;
case 'I': case 'i': /* Inited / Not */
if (*ptr == 'I')
pb.fileParam.ioFlFndrInfo.fdFlags |= 0x0100;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~0x0100;
break;
case 'D': case 'd': /* 0x0001 Desktop / Not */
if (*ptr == 'D')
pb.fileParam.ioFlFndrInfo.fdFlags |= fOnDesk;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~fOnDesk;
break;
case 'M': case 'm': /* Sharable / Not */
if (*ptr == 'M')
pb.fileParam.ioFlFndrInfo.fdFlags |= 0x0080;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~0x0080;
break;
case 'Z': case 'z': /* Always Switch / Do Not */
#ifdef NEVER_DEFINED
if (*ptr == 'Z')
pb.fileParam.ioFlFndrInfo.fdFlags |= fHasBundle;
else
pb.fileParam.ioFlFndrInfo.fdFlags &= ~fHasBundle;
#endif
break;
}
}
break;
case 'c': /* file creator */
ptr = (char *) &pb.fileParam.ioFlFndrInfo.fdCreator;
for (j = 0 ; argv[i+1][j] ; j++)
*ptr++ = argv[i+1][j];
for ( ; j < 4 ; j++)
*ptr++ = ' ';
break;
case 'd': /* creation date (mm/dd/yy [hh:mm[:ss] [AM | PM]]) [*] */
break;
case 'l': /* ICON location (horizontal,vertical) [*] */
break;
case 'm': /* modification date (mm/dd/yy [hh:mm[:ss] [AM | PM]]) [*] */
break;
case 't': /* file type */
ptr = (char *) &pb.fileParam.ioFlFndrInfo.fdType;
for (j = 0 ; argv[i+1][j] ; j++)
*ptr++ = argv[i+1][j];
for ( ; j < 4 ; j++)
*ptr++ = ' ';
break;
}
}
else {
sprintf(buffer, "option %s invalid.", argv[i]);
SetHandleSize(resultH, strlen(buffer) + 1);
if (MemError() == noErr)
strcpy(*resultH, buffer);
xpb->result = TCL_ERROR;
break;
}
}
if (xpb->result == TCL_OK) {
PBSetFInfo(&pb, FALSE);
if (pb.fileParam.ioResult != noErr) {
sprintf(buffer, "error #%d setting info for '%.32s'.",
pb.fileParam.ioResult, argv[1]);
SetHandleSize(resultH, strlen(buffer) + 1);
if (MemError() == noErr)
strcpy(*resultH, buffer);
xpb->result = TCL_ERROR;
}
}
}
}